from torch.utils.data import Dataset
from PIL import Image
import os

class MyData(Dataset):
    def __init__(self,root_dir,label_dir):
        self.root_dir = root_dir
        self.label_dir = label_dir
        self.path = os.path.join(self.root_dir,self.label_dir)
        self.img_path = os.listdir(self.path)

    def __getitem__(self, idx):
        img_name = self.img_path[idx]
        img_item_path = os.path.join(self.root_dir,self.label_dir,img_name)
        _img = Image.open(img_item_path)
        _label = self.label_dir
        return _img,_label

    def __len__(self):
        return len(self.img_path)


ants_dataset = MyData("dataset/train","ants")
bee_dataset = MyData("dataset/train","bees")
img,label = ants_dataset[0]
bee_img,bee_label = bee_dataset[0]
#img.show()
#bee_img.show()
train_set = ants_dataset + bee_dataset
